<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-Strict.dtd">
<%@taglib prefix="s" uri="/struts-tags"%>
<%@ page
	import="com.onlineMIS.common.Common_util,java.util.Date,java.text.SimpleDateFormat"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=8" />
<title>千禧宝贝连锁店管理信息系统</title>
<%@ include file="../../../common/Style.jsp"%>
<script>
var dataGrid ;
$(document).ready(function(){
	parent.$.messager.progress('close'); 
	
	var params = $.serializeObject($('#basicDataForm'));

	dataGrid = $('#dataGrid').datagrid({
		url : 'basicDataJSON!getBasicData',
		queryParams: params,
		fit : true,
		border : false,
		pagination : true,
		pageSize : 20,
		pageList : [ 20, 25],	
		checkOnSelect : false,
		selectOnCheck : false,
		singleSelect:true,
		nowrap : false,
		rownumbers : true,
		rowStyler: function(index,row){
			var style = "";
			if (row.status == 0)
				style += 'color:red;';
			return style;
		},		
		columns : [ [  {
				field : 'category_Name',
				title : '名称',
				width : 140,
				align: 'center'
			    },{
					field : 'category_Code',
					title : '编码',
					width : 120,
					align: 'center'
				}, {
					field : 'typeS',
					title : '所属',
					width : 90,
					align: 'center'
			    }, {
					field : 'status',
					title : '状态',
					align: 'center',
					width : 90,
					formatter: function (value, row, index){
						if (value == 0)
							return '锁定';
						else
							return '正常';
					},					
				}, {			    	
				field : 'action',
				title : '编辑',
				width : 60,
				align: 'center',
				formatter : function(value, row, index) {
					var str = '';
					str += $.formatString('<a href="#" onclick="EditCategory(\'{0}\');"><img border="0" src="{1}" title="编辑类别"/></a>', row.category_ID, '<%=request.getContextPath()%>/conf_files/easyUI/themes/icons/text_1.png');
					return str;
				}
		}]],
		toolbar : '#toolbar',
	});

});

function EditCategory(categoryId){
	var params = "formBean.basicData=category";
	if (categoryId != 0)
	   params += "&formBean.basicDataId =" + categoryId;

	$.modalDialog({
		title : "添加/更新品类",
		width : 430,
		height : 250,
		modal : false,
		draggable:false,
		href : 'basicData!preAddBasicData?' + params,
		
	});
}
function refresh(){
	$('#dataGrid').datagrid('load', $.serializeObject($('#basicDataForm')));
}
function clearSearch(){
	$("#categoryName").val("");
	refresh();
}

function oneKeyCode(){
	    var params=$("#updateCategoryForm").serialize();
        $.post("basicDataJSON!oneKeyCategoryCode",params, updateCategoryCodeBKProcess,"json");	
	
}
function updateCategoryCodeBKProcess(date){
	var response = date.response;
	var returnCode = response.returnCode;
	$.messager.alert('提示',response.message,'info');
	 refresh();
}
function changeBasicData(value){
    if (value != ""){
    	document.basicDataForm.action="basicData!changeBasicData";
    	document.basicDataForm.submit(); 
    }
}
</script>
</head>
<body>
	<div class="easyui-layout" border="false"
		style="width: 600px; height: 780px">
		<div data-options="region:'north',border:false" style="height: 75px;">
			<script>
			function changeBasicData(value){
			    if (value != ""){
			    	document.basicDataForm.action="basicData!changeBasicData";
			    	document.basicDataForm.submit(); 
			    }
			}
			</script>
			<s:form id="basicDataForm" name="basicDataForm" action=""
				theme="simple">
				<table width="90%" border="0">
					<tr>
						<td width="90"><strong>基础资料类别：</strong></td>
						<td colspan="7">		     
						 <s:select cssClass="easyui-combobox" style="width:120px"   id="basicData" data-options="onChange:function(param1, param2){changeBasicData(param1);}" name="formBean.basicData"  list="#{'year':'年份','quarter':'季度','brand':'品牌','categoryLevel':'产品线','category':'货品类别','color':'颜色','productUnit':'货品单位','numPerHand':'齐手数量','inventory':'仓库','tag':'标签','tagGroup':'标签组','expenseHqType':'费用类型'}" listKey="key" listValue="value"  headerKey=""  headerValue="请选择"/>
						</td>
					</tr>
					<tr>
						<td colspan="2">						       					
						      状态:<s:select cssClass="easyui-combobox"  style="width:90px" name="formBean.category.status"
								list="#{'1':'正常','0':'锁定'}"
								listKey="key" listValue="value" headerKey="-1" headerValue="-全部-" />					
						      名称:<s:textfield id="categoryName"
								name="formBean.category.category_Name" cssClass="easyui-textbox"
								style="width:80px" />
								
						</td>

					</tr>
					<tr>
						<td></td>
						<td></td>
					</tr>
				</table>
			</s:form>
		</div>
		<div data-options="region:'center',border:false">
			<table id="dataGrid">
			</table>

			<div id="toolbar" style="display: none;">
				<a onclick="refresh();" href="javascript:void(0);"
					class="easyui-linkbutton"
					data-options="plain:true,iconCls:'icon-search'">查询</a> 		
						
				<a onclick="EditCategory(0);" href="javascript:void(0);"
					class="easyui-linkbutton"
					data-options="plain:true,iconCls:'icon-add'">添加</a> 
				<a onclick="refresh();" href="javascript:void(0);"
					class="easyui-linkbutton"
					data-options="plain:true,iconCls:'icon-reload'">刷新</a>
				<a onclick="oneKeyCode();" href="javascript:void(0);"
					class="easyui-linkbutton"
					data-options="plain:true,iconCls:'icon-tip'">货品一键编号</a> 
			</div>
		</div>
	</div>
</body>
</html>